package com.xiaotu.singleton.type8;

import javax.sound.midi.Soundbank;

/**
 * @author 张晓
 * @create 2020-06-18 22:08
 */
public class SingletonTest08 {

    public static void main(String[] args) {
        Singleton instance = Singleton.INSTANCE;
        Singleton instance1 = Singleton.INSTANCE;
        System.out.println(instance == instance1);
        System.out.println(instance.hashCode());
        System.out.println(instance1.hashCode());
    }
}
//使用枚举，可以实现单例，推荐
enum Singleton{
    INSTANCE;//属性
    public void sayOk(){
        System.out.println("ok~");
    }
}